#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int main()
{
	int a, b;
	int tmp;
	scanf("%d %d", &a, &b);
	int m = a > b ? a : b;
	int n = a < b ? a : b;
	tmp = m % n;
	while (tmp)
	{
		m = n;
		n = tmp;
		tmp = m % n;
	}
	printf("%d", n);

	return 0;
}